/**
 *@author ZY
 *@date 2022/2/10
 *@Description:请求方式的封装
*/

// 封装axios的post请求
import request from "../libs/utils.request";
// import {request} from "./service";

export function post(url, params) {
    return new Promise((resolve, reject) => {
        request({
            url: url,
            method: "POST",
            data: params,
        }).then(response => {
            resolve(response.data)
        }).catch((error) => {
            reject(error)
        })
    })
}

export function postById(url, params) {
    return new Promise((resolve, reject) => {
        request({
            url: url,
            method: "POST",
            params: params,
        }).then(response => {
            resolve(response.data)
        }).catch((error) => {
            reject(error)
        })
    })
}

// 封装axios的get请求
export function get(url, params) {
   
    return new Promise((resolve, reject) => {
        request({
            url: url,
            method: "GET",
            params: params,
        }).then(response => {
            resolve(response.data)
        }).catch((error) => {
            reject(error)
        })

    })
}

export function del(url, params) {
    return new Promise((resolve, reject) => {
        request({
            url: url,
            method: "delete",
            params: params,
        }).then(response => {
            resolve(response.data)
        }).catch((error) => {
            reject(error)
        })
    })
}

export function put(url, params) {
    return new Promise((resolve, reject) => {
        request({
            url: url,
            method: "put",
            data:params
        }).then(response => {
            resolve(response.data)
        }).catch((error) => {
            reject(error)
        })
    })
}


export function loginPost(url, params) {
    return new Promise((resolve, reject) => {
        request({
            url: url,
            method: "POST",
            params: params,
        }).then(response => {
            resolve(response)
        }).catch((error) => {
            reject(error)
        })
    })
}